package zdream.pmfield.stage.action;

import java.util.Objects;

import zdream.pmfield.stage.object.FoeActor;
import zdream.pmfield.stage.object.Seat;
import zdream.pmfield.stage.object.StageMove;

/**
 * @author Zdream
 * @date 2023-11-13
 * @since 0.0.1
 */
public class AttackAction extends StageAction {
	public final FoeActor foe;
	public StageMove move;

	/**
	 * 部分技能的 target 是 foe 不是 seat
	 */
	public FoeActor targetFoe;
	public Seat targetSeat;

	public AttackAction(FoeActor foe) {
		this.foe = Objects.requireNonNull(foe);
	}

	@Override
	public int getInnerId() {
		return foe.innerId;
	}

	@Override
	public boolean isForAttack() {
		return true;
	}

	@Override
	public AttackAction asAttack() {
		return this;
	}

	@Override
	public StageAction copy() {
		AttackAction action = new AttackAction(foe);
		action.move = this.move;
		action.targetFoe = this.targetFoe;
		action.targetSeat = this.targetSeat;
		return action;
	}

	@Override
	public String toString() {
		if (move == null) {
			return "";
		}

		StringBuilder builder = new StringBuilder(128);
		move.foe.appendStringWithoutHp(builder);
		builder.append(' ').append("使用").append(' ');
		builder.append(move);
		builder.append(' ').append("目标是");
		if (targetFoe != null) {
			builder.append(' ');
			targetFoe.appendStringWithoutHp(builder);
		} else if (targetSeat != null) {
			builder.append("位置").append(' ');
			targetSeat.appendStringWithoutFoe(builder);
		} else {
			builder.append("不知道哪里");
		}

		return builder.toString();
	}
}
